<template>
    <view class="rxlist">
        <view v-for="(item, index) in good_list" :key="index">
            <image :src="img_url + item.pic" @tap="productdetails" :data-id="item.id" mode="aspectFill" class="cpimg"></image>

            <view class="txt9" @tap="productdetails" :data-id="item.id">
                <view @tap="productdetails" :data-id="item.id">{{ item.name }}</view>
                <view @tap="productdetails" :data-id="item.id">{{ item.label }}</view>
                <view @tap="productdetails" :data-id="item.id">
                    <span class="txt10">￥</span>
                    {{ user.vip == 0 ? item.price : item.vip_price }}
                </view>
            </view>
        </view>
    </view>
</template>

<script>
const app = getApp();
export default {
    data() {
        return {
            img_src: app.globalData.img_src,
            img_url: app.globalData.img_urls,
            good_list: [],
            country: uni.getStorageSync('country') ? uni.getStorageSync('country') : 2,
            navBarHeight: '',
            menuRight: '',
            menuBotton: '',
            menuHeight: ''
        };
    },
    /**
     * 组件的属性列表
     */
    props: {
        good_list: {
            type: Array,
            default: ''
        },
        cart_list: {
            type: Array,
            default: ''
        },
        checks: {
            type: Number,
            default: ''
        },
        user: {
            type: Object,
            default: ''
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        attached: function () {
            const that = this;
            // 获取系统信息
            const systemInfo = uni.getSystemInfoSync();
            // 胶囊按钮位置信息
            const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
            // 导航栏高度 = 状态栏到胶囊的间距（胶囊距上距离-状态栏高度） * 2 + 胶囊高度 + 状态栏高度
            this.setData({
                navBarHeight: (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight,
                menuRight: systemInfo.screenWidth - menuButtonInfo.right,
                menuBotton: menuButtonInfo.top - systemInfo.statusBarHeight,
                menuHeight: menuButtonInfo.height
            });
        },

        qrprice(e) {
            this.$emit('qrprices', {
                detail: data
            });
        },

        productdetails(e) {
            var id = e.currentTarget.dataset.id;
            if (uni.getStorageSync('token')) {
                uni.navigateTo({
                    url: '/subcontract/shopdetail/shopdetail?id=' + id
                });
            } else {
                app.globalData.show('请先登录~');
            }
        }
    },
    mounted() {
        // 处理小程序 attached 生命周期
        this.attached();
    },
    created: function () {}
};
</script>
<style>
.rxlist {
    width: 100%;
    height: auto;
    display: table;
    margin: auto;
}
.rxlist > view {
    width: 48%;
    height: auto;
    display: table;
    margin-bottom: 15px;
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid #f7f7f7;
    background-color: #fff;
    border-radius: 20rpx;
    overflow: hidden;
    position: relative;
}
.rxlist > view:nth-child(odd) {
    float: left;
}
.rxlist > view:nth-child(even) {
    float: right;
}
.cpimg {
    width: 100%;
    height: 173px;
    display: table;
}
.txt9 {
    width: 100%;
    height: auto;
    display: table;
    box-sizing: border-box;
    padding: 7px 5px;
    position: relative;
    padding-bottom: 3px;
}
.txt9 > view:nth-child(1) {
    width: 100%;
    height: 22px;
    font-size: 26rpx;
    font-family: PingFang;
    font-weight: 500;
    color: #282724;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    margin-bottom: 2px;
}
.txt9 > view:nth-child(2) {
    width: 100%;
    height: 22px;
    font-size: 20rpx;
    font-family: PingFang;
    font-weight: 400;
    color: #666666;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    margin-bottom: 2px;
}
.txt9 > view:nth-child(3) {
    width: 100%;
    height: auto;
    font-size: 36rpx;
    font-family: PingFang;
    font-weight: bold;
    color: #ee321f;
}
.txt10 {
    font-size: 30rpx !important;
}
.txt11 {
    width: 100%;
    height: auto;
    display: table;
    box-sizing: border-box;
    padding: 7px 0px;
    position: relative;
    padding-bottom: 3px;
    position: absolute;
    left: 0px;
    bottom: 0px;
}
.txt11 > view:nth-child(1) {
    width: 100%;
    height: auto;
    font-size: 36rpx;
    font-family: PingFang;
    font-weight: bold;
    color: #ee321f;
}
.txt10 {
    font-size: 30rpx !important;
}
.txt11 > view:nth-child(2) {
    font-size: 24rpx;
    font-family: PingFang;
    font-weight: 500;
    text-decoration: line-through;
    color: #b4acac;
    margin-bottom: 3px;
}
.cart {
    width: 40px;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    right: 0px;
    bottom: 10px;
}
.cart > image {
    width: 20px;
    height: 20px;
}
.rxlist1 {
    width: 100%;
    display: table;
    margin: auto;
}
.rxlist1 > view {
    width: 100%;
    display: table;
    margin: auto;
    padding: 10px;
    margin-bottom: 15px;
    padding-left: 140px;
    height: 120px;
    box-sizing: border-box;
    position: relative;
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 10px;
}
.cpimg1 {
    width: 120px;
    height: 120px;
    display: table;
    position: absolute;
    top: 10px;
    left: 10px;
    border-radius: 10rpx;
}
.listcon {
    width: 100%;
    height: 120px;
    display: table;
    position: relative;
}
.xtxt {
    width: 100%;
    height: auto;
    display: table;
    font-size: 14px;
    color: #282724;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.xtxt1 {
    width: auto;
    height: 30px;
    display: inline-block;
    padding: 0px 15px;
    margin-top: 5px;
    background: linear-gradient(-90deg, #ffffff 0%, #edeaff 100%);
    font-size: 24rpx;
    font-family: PingFang;
    font-weight: 500;
    color: #7f5eb3;
    line-height: 30px;
}
.txt13 {
    width: 100%;
    height: auto;
    display: table;
    font-size: 24rpx;
    font-family: PingFang;
    font-weight: 500;
    text-decoration: line-through;
    color: #b4acac;
    line-height: 40rpx;
}
.conts {
    width: 100%;
    height: auto;
    display: table;
    position: absolute;
    left: 0px;
    bottom: 0px;
}
</style>
